/**
 *       Copyright (c) 2012 Lukas Zaruba
 *
 *   This file is part of Robot Playground.
 *
 *   Robot Playground is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   Robot Playground is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Lesser General Public License for more details.
 *
 *   You should have received a copy of the GNU Lesser General Public License
 *   along with Robot Playground. If not, see <http://www.gnu.org/licenses/>.
 */
package net.zarubsys.robotplayground.gui.scriptprogram.wizard;

import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;

/**
 * ScriptProgramSourceSelectionPage
 *
 * @author Lukas Zaruba, lukas.zaruba@gmail.com
 */
public class ScriptProgramSourceSelectionPage extends WizardPage {
	
	private ProgramSourceSelection source = ProgramSourceSelection.NEW;
	
	public ScriptProgramSourceSelectionPage(String pageName) {
		super(pageName);
	}

	@Override
	public void createControl(Composite parent) {
		Composite composite = new Composite(parent, SWT.NONE);
		composite.setLayout(new RowLayout(SWT.VERTICAL));
		
		Button newRadio = new Button(composite, SWT.RADIO);
		newRadio.setText("Create new script");
		newRadio.setSelection(true);
		newRadio.addSelectionListener(new SelectionListener() {
			
			@Override
			public void widgetSelected(SelectionEvent e) {
				source = ProgramSourceSelection.NEW;
			}
			
			@Override
			public void widgetDefaultSelected(SelectionEvent e) {
				// ignore
			}
			
		});
		
		Button existingRadio = new Button(composite, SWT.RADIO);
		existingRadio.setText("Choose existing script");
		existingRadio.addSelectionListener(new SelectionListener() {
			
			@Override
			public void widgetSelected(SelectionEvent e) {
				source = ProgramSourceSelection.EXISTING;
			}
			
			@Override
			public void widgetDefaultSelected(SelectionEvent e) {
				// ignore
			}
			
		});
		
		setControl(composite);
	}
	
	public ProgramSourceSelection getSource() {
		return source;
	}
	
	public static enum ProgramSourceSelection {
		
		NEW, EXISTING;
		
	}

}

